window.onload = function() {
    var tel = /^1[3|5|4|7|8]\d{9}$/ // 手机号码的正则
    var regtel = document.querySelector('#tel');
    var qq = /^[1-9]\d{4,}$/
    var regqq = document.querySelector('#qq');

    var name = /^[\u4e00-\u9fa5]{2,8}$/
    var nc = document.querySelector('#nc');

    var regmas = /^[0-9]{6}$/
    var msg = document.querySelector('#msg');

    var password = /^[a-zA-Z0-9_.-]{6,16}$/
    var regpwd = document.querySelector('#pwd');

    var qr = document.querySelector('#surepwd');
    fn(tel, regtel);
    fn(qq, regqq);
    fn(name, nc);
    fn(regmas, msg);
    fn(password, regpwd);

    qr.onblur = function() {
        if (qr.value == regpwd.value) {
            this.nextElementSibling.className = 'success';
            this.nextElementSibling.innerHTML = ' <i class="success_icon"></i>  输入正确';
        } else {
            this.nextElementSibling.className = 'error';
            this.nextElementSibling.innerHTML = ' <i class="error_icon"></i>  密码错误';
        }
    }

    function fn(reg, regdata) {
        regdata.onblur = function() {
            if (reg.test(regdata.value)) {

                this.nextElementSibling.className = 'success';
                this.nextElementSibling.innerHTML = ' <i class="success_icon"></i>  输入正确';

            } else {
                this.nextElementSibling.className = 'error';
                this.nextElementSibling.innerHTML = ' <i class="error_icon"></i>  格式错误';
            }
        }
    }


}